<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>	
		<script src="../hyn/js/check/checkFrequency.js"></script>
<!--添加需要搜索的工具  -->
	<div id="huotb" style="padding:5px;height:auto">
		<div>
		<a id="huoadd" href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-add',plain:true">添加</a>
		<a href="javascript:void(0)" class="easyui-linkbutton" data-options="iconCls:'icon-remove',plain:true" onclick="removeit()">删除</a>
		 <sapn style="margin-left:60%">搜索文本：</sapn> 
		 <input  class="easyui-searchbox" data-options="searcher:searchname,prompt:'请输入需要搜索的名称'" style="width: 20%">
		</div>
	</div>
    <table id="huodg" class="easyui-datagrid"></table>
	<!-- 弹出新增窗口代码开始 -->
	<div id="huodd" class="easyui-dialog" style="width:600px;height:300px"
		data-options="modal:true,closed:true,title:'添加班次信息'">
		<form id="ff" method="post" action="addemp">
		    <div id="holidaybody" style="margin:-30px 20%">
		        <input class="easyui-textbox holidaytext" type="text" style="display:none;width:10px;" id="frequencyId"/><br>
		         <input class="easyui-textbox holidaytext" type="text" style="display:none;width:10px;" id="maker"/><br>
		          <input class="easyui-textbox holidaytext" type="text" style="display:none;width:10px;" id="makeTime"/><br>
				<label for="dname">班次名称:</label>
				<input class="easyui-validatebox holidaytext" type="text" id="frequencyName" name="dname"  placeholder="请输入班次名称  " /><br>
				<label for="dname">班次类别:</label>
				<input class="easyui-validatebox holidaytext" type="text" id="category" name="dname"  placeholder="请输入类别名称  " /><br>
				<label for="dname">备 &nbsp &nbsp&nbsp&nbsp注:</label>
				<textarea rows="5" cols="20" id="remark" class="holidayremaker"></textarea><br>
				<label for="dname" style="margin-left:10%" >启用:</label>
				<input class="easyui-validatebox" type="checkbox" id="systemUse" name="dname"  />
				<label for="dname" style="margin-left:20%">停用:</label>
				<input class="easyui-validatebox" type="checkbox" name="dname"  />
		    </div>
		</form>
	</div>

	<!-- 弹出新增窗口代码结束 -->
	<script type="text/javascript">
	$("#huoadd").linkbutton({
		onClick : function() {
			$("#huodd").window("open");
		}
	});
	// 定义底部保存，清空，取消按钮
	$('#huodd').dialog({
		buttons : [ {
			text : '保存',
			iconCls : 'icon-save',
			handler : function() {
				$('#ff').form('submit', {
					onSubmit : function(param) {
						var frequencyId= $("#frequencyId").val();
						var frequencyName= $("#frequencyName").val();
						var category=$("#category").val();
						var remark = $("#remark").val();
						var systemUse = ""+$("#systemUse").is(":checked");
						var frequencys = [];
						if(frequencyId==null||frequencyId===''){
							var maker = "huohuo"/* ${user} */;
							var frequency = {
									frequencyName : frequencyName,
									category:category,
									remark : remark,
									systemUse : systemUse,
									maker : maker	
								};
							    frequencys.push(frequency);
								var jsondata = JSON.stringify(frequencys);
							    alert(jsondata);
							$.ajax({
								url : "../check/addcheckFrequency",
								data : {"jsondata" : jsondata},
								success : function(e) {
									if (e === "ok") {
										$.messager.alert("存储成功");
		                               $('#huodg').datagrid('load');
									}
								}
							});
						}
						else{
							var maker = $("#maker").val();	
							var makeTime = $("#makeTime").val();
							var updateEmp =  "huohuo"/* ${user} */;
							var frequency= {
									frequencyId: frequencyId,
									frequencyName : frequencyName,
									category:category,
									remark : remark,
									systemUse : systemUse,
									maker : maker, 
									makeTime:makeTime,
									updateEmp:updateEmp
								};
							   frequencys.push(frequency);
								var update_jsondata = JSON.stringify(frequencys);
								 alert(update_jsondata);
							$.ajax({
								url : "../check/updatecheckFrequency",
								data : {"update_jsondata" :update_jsondata},
								success : function(e) {
									if (e == "ok") {
									  alert("修改成功");
		                               $('#huodg').datagrid('load');
									}
								}
							});
						}
					},
					success : function(data) {

					}
				});
			}
		}, {
			text : '清空',
			iconCls : 'icon-clear',
			handler : function() {
				$('#ff').form('clear');
			}
		}, {
			text : '取消',
			iconCls : 'icon-cancel',
			handler : function() {
				$("#huodd").window("close");
			}
		} ]
	});
	</script>
</body>
</html>